package com.cjj.common.utils;

import com.cjj.common.framework.holder.RequestHolder;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpHeaders;

import java.util.Objects;

/**
 * @author baozhuangyu
 * @since  2021/4/27  9:41
 */
public class RequestUtil {
    public static String getToken(){
        String token = Objects.requireNonNull(RequestHolder.getRequest()).getHeader(HttpHeaders.AUTHORIZATION);
        if (StringUtils.isNotBlank(token) && token.startsWith("Bearer ")){
            return token.substring(7);
        }
        return null;
    }
}
